package org.example;

import java.io.IOException;
import java.util.Arrays;

public class IO_Demo5 {
    public static void main(String[] args) throws IOException {
        //java中编码方式
        String str = "你好";
        byte[] bytes = str.getBytes();//默认方式
        System.out.println(Arrays.toString(bytes));

       byte[] bytes1=str.getBytes("UTF-8");
        System.out.println(Arrays.toString(bytes1));

        //解码方式
        String s = new String(bytes1,"UTF-8");//指定方式
        System.out.println(s);

        //默认方式解码
        String s1 = new String(bytes);
        System.out.println(s1);
    }
}
